const router = require('koa-router')()
const controller = require('../../controller/api/cabines')
const archives = require('../../controller/archives')
const mssql =  require('../../lib/mssql')
const setup  = require('../../controller/setup')
const preprocessed  = require('../../controller/preprocessed')

router.prefix('/geek')

router.get('/:room/:area', async (ctx, next) => {
    console.log(ctx.params); 
    await ctx.render('index',{
        title: '我是首页',
        body: '我是内容啊',
        area: ctx.params['area'],
        room: ctx.params['room'],
    });
})



router.get('/:room/:area/ventilate', controller.ventilate)
router.get('/:room/:area/areaColumnConfiguration', controller.areaColumnConfiguration)
router.get('/:room/:area/initialStatus', controller.initialStatus)
router.get('/:room/:area/heartbeats', controller.heartbeats)
router.get('/:room/:area/open', controller.open)
router.get('/:room/:area/close', controller.close)
router.get('/:room/:area/stop', controller.stop)
router.get('/:room/:area/setup', controller.setup)
router.get('/:room/:area/setupTable', setup.get)
router.put('/:room/:area/setupTable', setup.put)
router.get('/:room/:area/archives/', archives.list)
router.get('/:room/:area/archives/query', archives.query)
router.get('/:room/:area/archives/preprocessed', archives.preprocessed)
router.get('/test/', controller.test)


/*


router.get('/mssql', async (ctx, next) => {
   var sql = "SELECT TOP 10  from sys_Users  ORDER BY id DESC";
    mssql(sql, result => {

        console.log("================?");
        res.send(result);
    })
 
        console.log("================");

   await ctx.render('index',{
        title: '我是首页',
        body: '我是内容啊'
    });
})
router.get('/mssql', (req, res) => {
    var sql = "SELECT TOP 10  from user  ORDER BY id DESC";
    mssql(sql, result => {
        console.log(result);
        res.send(result);
    })

})
*/
 
/*
router.get('/find', controller.find)

router.post('/insert', controller.insert)

router.delete('/delete', controller.delete)

router.put('/update', controller.update)
*/
module.exports = router